package cn.org.rookie.mybatismapper;

import cn.org.rookie.mybatismapper.sql.Wrapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BaseMapper<E, P> {

    @InsertProvider(type = BaseMapperProvider.class, method = "insert")
    int insert(E param);

    @DeleteProvider(type = BaseMapperProvider.class, method = "delete")
    int delete(P param);

    @DeleteProvider(type = BaseMapperProvider.class, method = "deleteByWrapper")
    int deleteBy(@Param("wrapper") Wrapper wrapper);

    @UpdateProvider(type = BaseMapperProvider.class, method = "update")
    int update(@Param("param") E param);

    @UpdateProvider(type = BaseMapperProvider.class, method = "updateByWrapper")
    int updateBy(@Param("param") E param, @Param("wrapper") Wrapper wrapper);

    @SelectProvider(type = BaseMapperProvider.class, method = "find")
    E find(P param);

    @SelectProvider(type = BaseMapperProvider.class, method = "findByWrapper")
    List<E> findBy(@Param("wrapper") Wrapper wrapper);

    @SelectProvider(type = BaseMapperProvider.class, method = "findAll")
    List<E> findAll();
}
